<?php
	class Class_plan extends CI_Model{

	 	function __construct(){
          	parent::__construct();
      	}


        function get_tomorrow_class_plan_user($conditions = array()){
            $tomorrow_begin_time = date("Y-m-d",strtotime("+1 day"));
            $sql = "SELECT * FROM {$this->db->dbprefix}o2o_class_plan WHERE class_date = '{$tomorrow_begin_time}'";
            $result = $this->db->query($sql)->result_array();
            return $result;
        }

        function get_classes_user_openid($class_id){
            $sql = "SELECT c_stu.class_id, u.open_id, c.course_name, c.class_name, sc.name FROM {$this->db->dbprefix}o2o_class_student AS c_stu ";
            $sql .= "LEFT JOIN {$this->db->dbprefix}o2o_school_student AS ss ON(ss.student_id = c_stu.student_id) ";
            $sql .= "LEFT JOIN {$this->db->dbprefix}user AS u ON(u.id=ss.user_id) ";
            $sql .= "LEFT JOIN {$this->db->dbprefix}o2o_class AS c ON(c.id=c_stu.class_id) ";
            $sql .= "LEFT JOIN {$this->db->dbprefix}o2o_school_campus AS sc ON(c.campus=sc.id) ";
            $sql .= "WHERE c_stu.class_id IN($class_id) AND u.open_id != '' AND u.open_id IS NOT NULL GROUP BY u.id";
            return $this->db->query($sql)->result_array();
        }
	}